<?php
/**
 * Created by PhpStorm.
 * User: zyark
 * Date: 2018/3/28
 * Time: 15:34
 */

namespace app\admin\controller\log;


use app\common\controller\Backend;

/**
 * 功能冻结记录
 * Class MoneyLog
 * @package app\admin\controller\log
 */
class FreezeLog extends Backend
{
    protected $model = null;

    public function _initialize(){
        parent::_initialize();
        $this->model = model('FreezeLog');
    }

    /**
     * @param $ids='' string 用户id
     * 查看
     * @return mixed
     */
    public function index($ids='')
    {
        if ($this->request->isAjax())
        {
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $total = $this->model
                ->where($where)
                ->order($sort, $order)
                ->count();

            $list = $this->model
                ->where($where)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();
            foreach ($list as $key=>&$value){
                $value['user_nickname'] = model('User')->where(array('id'=>$value['user_id']))->value('nickname');
                $value['operation_nickname'] = model('User')->where(array('id'=>$value['operation_id']))->value('nickname');
                $node_ids = explode(',',$value['node_ids']);
                $node_text = '';
                foreach ($node_ids as $k=>$v){
                    $name = model('FunctionNode')->where(array('id'=>$v))->value('name');
                    if($k == 0){
                        $node_text = $name;
                    }else{
                        $node_text.=','.$name;
                    }

                }
                $value['function_text'] = $node_text;
            }
            unset($value);
            $result = array("total" => $total, "rows" => $list);
            return json($result);
        }
        return $this->view->fetch();
    }
}